package com.cobra.rdd.operator.transform

import org.apache.spark.{HashPartitioner, SparkConf, SparkContext}

//key-value类型 partitionby
object Spark20_RDD_Operator_Transform_partitionBy {
  def main(args: Array[String]): Unit = {
    val sparkConf = new SparkConf().setMaster("local[*]").setAppName("Spark20_RDD_Operator_Transform_partitionBy")
    val sc = new SparkContext(sparkConf)
    val rdd = sc.makeRDD(List(1, 2, 3, 4),2)
    val mapRDD = rdd.map((_,1))
    mapRDD.partitionBy(new HashPartitioner(2)).saveAsTextFile("output")
    sc.stop()
  }
}
